package cn.iocoder.yudao.module.member.controller.app.leaveword;

import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.member.controller.admin.leaveword.vo.LeaveWordSaveReqVO;
import cn.iocoder.yudao.module.member.controller.app.leaveword.vo.AppLeaveWordSaveReqVO;
import cn.iocoder.yudao.module.member.service.leaveword.LeaveWordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 用户留言")
@RestController
@RequestMapping("/member/leave-word")
@Validated
public class AppLeaveWordController {

    @Resource
    private LeaveWordService leaveWordService;

    @PostMapping("/create")
    @Operation(summary = "创建用户留言")
    public CommonResult<Long> createLeaveWord(@Valid @RequestBody AppLeaveWordSaveReqVO createReqVO) {
        LeaveWordSaveReqVO saveReqVO = BeanUtil.toBean(createReqVO, LeaveWordSaveReqVO.class);
        saveReqVO.setUserId(SecurityFrameworkUtils.getLoginUserId());
        return success(leaveWordService.createLeaveWord(saveReqVO));
    }

}